home *** CD-ROM | disk | FTP | other *** search
/ Champak 29 / Volume 29 - JOGO DISK .iso / Games / jungle_adventure.swf / scripts / __Packages / SSViewport.as < prev    next >
Text File  |  2006-11-29  |  2KB  |  62 lines

  1. class SSViewport extends GDK.Viewport
  2. {
  3.    var leftSector = 0;
  4.    var rightSector = 0;
  5.    var topSector = 0;
  6.    var bottomSector = 0;
  7.    var left = 0;
  8.    var right = 0;
  9.    var top = 0;
  10.    var bottom = 0;
  11.    var screenWidth = 0;
  12.    var screenHeight = 0;
  13.    var halfWidth = 0;
  14.    var halfHeight = 0;
  15.    var focusDepth = -450;
  16.    var hither = 50;
  17.    var yon = 20000;
  18.    function SSViewport()
  19.    {
  20.       super();
  21.    }
  22.    function onAddToWorld()
  23.    {
  24.       this.halfWidth = this.screenWidth * 0.5;
  25.       this.halfHeight = this.screenHeight * 0.5;
  26.       this.camOffset = new Vector();
  27.       this.setFieldOfView(this.FOV);
  28.       this.focusDepth = - (this.wTan = this.halfWidth / this.tanFOV);
  29.       this.hTan = this.halfHeight / this.tanFOV;
  30.    }
  31.    function onMove()
  32.    {
  33.       this.changed = true;
  34.       this.right = (this.left = this.x - this.halfWidth) + this.screenWidth;
  35.       this.bottom = (this.top = this.y - this.halfHeight) + this.screenHeight;
  36.       var _loc2_ = this.leftSector != (this.leftSector = Math.floor(this.left / SSGlobal.GRID_SIZE - 0.5));
  37.       var _loc3_ = this.topSector != (this.topSector = Math.floor(this.top / SSGlobal.GRID_SIZE - 0.5));
  38.       var _loc4_ = this.rightSector != (this.rightSector = Math.ceil(this.right / SSGlobal.GRID_SIZE + 0.5));
  39.       var _loc5_ = this.bottomSector != (this.bottomSector = Math.ceil(this.bottom / SSGlobal.GRID_SIZE + 0.5));
  40.       if(_loc2_ || _loc3_ || _loc4_ || _loc5_)
  41.       {
  42.          this.sectorChanged = true;
  43.       }
  44.    }
  45.    function setWatch(obj)
  46.    {
  47.       this.watch = obj;
  48.       this.moveTo(this.tx = obj.x,this.ty = obj.y,this.focusDepth);
  49.    }
  50.    function update(elapsed)
  51.    {
  52.       if(!this.watch)
  53.       {
  54.          return undefined;
  55.       }
  56.       var _loc2_ = this.watch.velocity.getNormalized();
  57.       this.camOffset.x += (_loc2_.x * 125 - this.camOffset.x) * elapsed;
  58.       this.camOffset.y += (_loc2_.y * 50 - this.camOffset.y) * elapsed;
  59.       this.moveTo(this.watch.x,this.watch.y,this.focusDepth);
  60.    }
  61. }
  62.